var reques = require('../../utils/util.js');
// pages/account/account.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    swi:[
      { id: 0, src: '../../image/qxtx/user/swi1.png' },
      { id: 1, src: '../../image/qxtx/user/swi2.png' },
    ],
    havelog: false,
    signed: false,
    span: 'none',
    nickName: null,
    touxiangurl: null,
    signday: 1,
    hiddenSign: true,
  },

  /**
  * 生命周期函数--监听页面加载
  */
  onLoad: function (options) {

  },

  /**
 * 生命周期函数--监听页面显示
 */
  onShow: function () {
    var that = this;
    that.setData({
      nickName: getApp().globalData.userInfo.nickName,
      touxiangurl: getApp().globalData.userInfo.avatarUrl,
    })
    // 页面显示时判断此微信是否绑定过，已经绑定过的havelog赋为true，即切换成已登录的头像栏
    if (getApp().globalData.logged == true) {
      that.setData({
        havelog: true,
      })
      // 查询个人资料
      var url = getApp().globalData.URL + 'user/searPer';
      var para = {}
      reques.gethttp(url, para)
        .then((res) => {
          if (res.data.code == 1) {
            getApp().globalData.accountINFO = res.data.data;
            console.log(getApp().globalData.accountINFO)
          }
        })
        .catch((errMsg) => {
          console.log(errMsg);
        })    
    }
  },

  loginIn:function(){
    // 在这里调接口判断是否有账号，没有跳到绑定页去绑定
    var that = this;
    if (getApp().globalData.logged == false){
      wx.navigateTo({
        url: '../bind/bind',
      })
    }else{
      wx.navigateTo({
        url: '../setgrzl/setgrzl',
      })
    }
  },

  // 签到
  signNow:function(){
    var that = this;
    if (getApp().globalData.logged == true){
      that.setData({
        // span: 'block',
        hiddenSign: false,
      });
      // setTimeout(function () {
      //   that.setData({
      //     signed: true,
      //   });
      // }, 400)
    }else{
      wx.showToast({
        icon: 'none',
        title: '请先登录',
      })
    }
  },

  closesign:function(){
    var that = this;
    that.setData({
      hiddenSign: true,
    });
  },

  signtoday:function(){
    var that = this;
    that.setData({
      span: 'block',
    });
      setTimeout(function () {
        that.setData({
          signed: true,
        });
      }, 400)
  },

  //充值中心
  myRisemoney:function(){
    wx.navigateTo({
      url: '../myrisemoney/myrisemoney',
    })
  },
  //我的钱包
  myWallet:function(){
    wx.navigateTo({
      url: '../mywallet/mywallet',
    })
  },
  //分享有礼
  myShare:function(){
    wx.navigateTo({
      url: '../myshare/myshare',
    })
  },
  //专家申请
  profession:function(){
    wx.navigateTo({
      url: '../profeWSZL/profeWSZL',
    })
  },
  // 我的信号
  myWIFI: function () {
    wx.navigateTo({
      url: '../mywifi/mywifi',
    })
  },
  // 我的消息
  myMSG: function () {
    wx.navigateTo({
      url: '../mymsg/mymsg',
    })
  },
  // 我的积分
  myPoints: function () {
    wx.navigateTo({
      url: '../mypoints/mypoints',
    })
  },
  // 我的客服
  myService:function(){
    wx.navigateTo({
      url: '../myservice/myservice',
    })
  },
  //帮助与反馈
  feedback:function(){
    wx.navigateTo({
      url: '../feedback/feedback',
    })
  },
  //我的邀请
  myInvite:function(){
    wx.navigateTo({
      url: '../myinvite/myinvite',
    })
  },
  //我的策略
  myStrategy:function(){
    wx.navigateTo({
      url: '../mystrategy/mystrategy',
    })
  },
  //我的跟单
  myDocument:function(){
    wx.navigateTo({
      url: '../mydocument/mydocument',
    })
  },
  //我的接单
  myRecive:function(){
    wx.navigateTo({
      url: '../myrecive/myrecive',
    })
  },
})